<?php
class Admin_Libraries_Html_Toolbar 
{
	private $_item = null;
	private $_template = null;
	private $_title = null;
	
	public function __construct($template = 'partial/toolbar.phtml')
	{
		$this->_template = $template;
	}
	
	public function addItem($title, $key, $alt='') 
	{
		$item = array('key' => $key,
					  'title' => $title,
					  'alt' => $alt);
		$this->_item[] = $item;
		return $this;
	}
	
	public function addTemplate($template = 'partial/toolbar.phtml')
	{
		$this->_template = $template;
		return $this;
	}
	
	public function addDivider()
	{
		$this->_item[] = array('key' => 'divider');
		return $this;
	}
	
	public function addTitle($title='')
	{
		$this->_title = $title;
		return $this;
	}
	
	public function display()
	{		
		$objViewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
		$objView = $objViewRenderer->view;
		$objView->title = $this->_title;
		$objView->item = $this->_item;
		$toolbar = $objView->render($this->_template);
		return $toolbar;
	}
}